home *** CD-ROM | disk | FTP | other *** search
/ Network Supervisor's Toolkit / Network Supervisor's Toolkit.iso / tools / nwtp06 / pwexp.pas < prev    next >
Pascal/Delphi Source File  |  1996-07-10  |  2KB  |  64 lines

  1. {$X+,B-,V-} {essential compiler directives}
  2.  
  3. program pwexp;
  4.  
  5. { Example for the nwConn unit / NwTP 0.6 API. (c) 1993,1995, R. Spronk }
  6.  
  7.  
  8. { Q: We're forcing our users to change their passwords every 40 days.
  9.      After the password expiration date, they have 3 grace logins, one
  10.      of which they should use to change their password. To force them
  11.      to change their passwords whenever they login after the expiration
  12.      date, we need an utility that returns a distinctive Errorlevel
  13.      whenever the password has expired.
  14.  
  15.   The following program will return an errorlevel 0 whenever the calling
  16.   station's password has expired (current date later than expiration
  17.   date). In all other cases (i.e. an expiration date wasn't set, 1 will
  18.   be returned.
  19. }
  20.  
  21. Uses nwMisc,NwBindry,nwConn,nwServ;
  22.  
  23. Function LaterDate(Var t1,t2):Boolean;
  24. Type Tascii3=array[1..3] of char;
  25. Var ta:Tascii3 ABSOLUTE t1;
  26.     tb:Tascii3 ABSOLUTE t2;
  27. begin
  28. if ta[1]<#80 then inc(ta[1],100);
  29. if tb[1]<#80 then inc(tb[1],100);
  30. LaterDate:=(ta>tb);
  31. end;
  32.  
  33. Var AccLev:Byte;
  34.     MyObjId:Longint;
  35.     MyObjName:string;
  36.     MyObjType:word;
  37.     Info:TloginControl;
  38.     Now:TnovTime;
  39.  
  40. begin
  41. IF GetBinderyAccessLevel(AccLev,MyObjId)
  42.    and GetBinderyObjectname(MyObjId,MyObjName,MyObjType)
  43.  then begin
  44.       IF GetObjectLoginControl(MyObjName,MyObjType,info)
  45.        then with Info.PasswordExpirationDate
  46.              do begin
  47.                 if (year=0) and (month=0) and (day=0)
  48.                  then begin
  49.                       writeln('PWEXP: Expiration date not set.');
  50.                       halt(1); { exp. date not set }
  51.                       end;
  52.                 GetFileServerDateAndTime(now);
  53.                 IF LaterDate(now,info.PasswordExpirationDate)
  54.                  then begin
  55.                       writeln('PWEXP: Password expired !');
  56.                       halt(0) { PW expired }
  57.                       end
  58.                  else halt(1);
  59.                 end;
  60.       end;
  61. writeln('PWEXP: Bindery read error. Shell wel geladen ? Ingelogd ?');
  62. halt(1);
  63. end.
  64.